<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <link href="/statics/css/login.css" type="text/css" rel="stylesheet">

    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<div class="login">
    <p style="text-align:center">
        <img src="/statics/images/logo.jpg" width="128" height="86.4">
    </p>
    <div class="message">人云易耘-注册</div>
    <div id="darkbannerwrap"></div>
    <label>请输入手机号</label>
    <input type="text" id="username" placeholder="手机号"><br/>

    <label style="font-family: Verdana;">请输入密码</label>
    &nbsp;&nbsp;&nbsp;<input type="password" id="password" placeholder="密码"><br/>

    <label>请再次输入密码</label>

    &nbsp;&nbsp;&nbsp;<input type="password" id="password2" placeholder="密码"><br/>
<!--    <hr class="hr15">-->
<!--    <label>请选择身份</label>-->

<!--    <input type="text" list="hostlist" id="UserType" placeholder="身份"><br/>-->
<!--    <hr class="hr15">-->
<!--    <div class="changeDiv">-->
<!--        <datalist id="hostlist">-->
<!--            <option>企业HR</option>-->
<!--            <option>求职者</option>-->
<!--        </datalist>-->
<!--    </div>-->
    <hr class="hr15">
    <input type="submit" value="注册" id="reg">
</div>

</body>
<script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm.min.js' charset='utf-8'></script>
<script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm-extend.min.js' charset='utf-8'></script>
<script>
    // $("#reg").click(function () {
    //     let user={};
    //     user.username = $("#username").val();
    //     user.password = $("#password").val();
    //     $.ajax({
    //         url:'user/reg',
    //         type:'post',
    //         dataType:'json',
    //         contentType:'application/json',
    //         data:JSON.stringify(user),
    //         success:function (data) {
    //             if(data.success){
    //                 $.toast("注册成功");
    //                 window.location.href='index.html';
    //             }else {
    //                 $.toast(data.errMsg);
    //             }
    //
    //         }
    //     });
    // })

    $("#reg").click(function () {
        let username=$("#username").val().trim();
        let password=$("#password").val().trim();
        let password2=$("#password2").val().trim();
        if (username==null||username==''){
            alert("用户名不能为空");
            return;
        }
        if (password==null||password==''){
            alert("密码不能为空");
            return;
        };
        if (password!=password2){
            alert("两次密码不一致");
            return;
        }
        var obj=new Object();
        obj.username=username;
        obj.password=password;
        $.ajax({
            url: 'register',
            type: 'post',
            data: obj,
            success: function (result) {
                if (result.code == 0) {//注册成功
                    location.href="/login.html";
                } else {
                    alert(result.msg);
                }
            }
        });
    })

</script>
</html>